package vip.xiaonuo.modular.util;

public class CardConverseUtil {


    public static String converseTo16Card(String deviceCard) {
        StringBuilder s = new StringBuilder(Long.toHexString(Long.parseLong(deviceCard)));
        for (int i = 0; i < 5; i++) {
            if (s.length()<8){
                s.insert(0, 0);
            }
        }
        char[] chars = s.toString().toUpperCase().toCharArray();
        return chars[6] + "" + chars[7] + "" + chars[4] + "" + chars[5] + "" + chars[2] + "" + chars[3] + "" + chars[0] + "" + chars[1];
    }

    public static String converseTo10Card(String oldCard) {
        StringBuilder oldCardBuilder = new StringBuilder(oldCard);
        for (int i = 0; i < 5; i++) {
            if (oldCardBuilder.length()<8){
                oldCardBuilder.insert(0, 0);
            }
        }
        oldCard = oldCardBuilder.toString();
        char[] chars = oldCard.toCharArray();
        String newCard = chars[6] + "" + chars[7] + "" + chars[4] + "" + chars[5] + "" + chars[2] + "" + chars[3] + "" + chars[0] + "" + chars[1];
        StringBuilder str = new StringBuilder(Long.parseLong(newCard, 16) + "");
        for (int i = 0; i < 5; i++) {
            if (str.length() < 10) {
                str.insert(0, 0);
            }
        }
        return str.toString();
    }
}
